package org.dwpd.controller.message;

import lombok.extern.slf4j.Slf4j;
import org.dwpd.domain.message.Comment;
import org.dwpd.domain.common.Result;
import org.dwpd.service.message.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RequestMapping("/comment")
@RestController
public class CommentController {

    @Autowired
    private CommentService commentService;

    /**
     * 添加评论
     */
    @PostMapping("/addComment")
    public Result addComment(@RequestBody Comment comment) {
        return commentService.addComment(comment);
    }

    /**
     * 获取当前用户贴的所有评论
     */
    @GetMapping("/getAllComment")
    public Result getAllComment(Integer messageId) {
        return commentService.getAllComment(messageId);
    }

    /**
     * 删除评论
     */
    @PostMapping("/deleteComment")
    public Result deleteComment(Integer commentId, Integer postUserId) {
        return commentService.deleteComment(commentId, postUserId);
    }
}
